\documentclass[12pt]{article}
\usepackage[a4paper]{geometry}
\setlength{\parindent}{0pt}
\usepackage{minted}

\newmint{perl}{}
\newmint[perlwithspaces]{perl}{showspaces}
\newmintinline{perl}{}
\newmintinline[perlinlinewithspaces]{perl}{showspaces}

\begin{document}

Text pre \mint{perl}{my $var = 1;} text after
Text pre \mint[showspaces]{perl}|my @arr = qw/a b c/;| text after
Text pre \mintinline{perl}{my $var = 1;}. text after
Text pre \mintinline[showspaces]{perl}|my @arr = qw/a b c/;| text after

Text pre \verb|\perl| text after
Text pre \perl|my $var = 1;| text after
Text pre \verb|\perlwithspaces| text after
Text pre \perlwithspaces|my $var = 1;| text after

Text pre \verb|\perlinline| text after
Text pre \perlinline/my $var = 1;/ text after
Text pre \verb|\perlinlinewithspaces| text after
Text pre \perlinlinewithspaces|my @arr = qw/a b c/;| text after

\end{document}
